set gSavePath to gMiscXobject(mSystemFolder) & "Preferences:Road Construction" & gFileSep
openXLib(gXobjPath & "StageToCast XObj")
openXLib(gXobjPath & "FixPalette XObj")
set gFixpal to FixPalette(mnew, the stageLeft, the stageTop, the stageRight, the stageTop)
openXLib(gXobjPath & "Johnny XObj")
set gFlushObject to Johnny(mnew)
else
openXLib(gXobjPath & "misc_x.dll")
set gMiscXobject to Misc_X(mnew)
set gSavePath to gMiscXobject(mWindowsDirectory) & "RCAGAMES" & gFileSep
openXLib(gXobjPath & "xobjdll.dll")
openXLib(gXobjPath & "eventq.dll")
openXLib(gXobjPath & "fileio.dll")
set gFlushObject to eventq(mnew)
end if
if gMiscXobject(mFolderExists, gSavePath) = 0 then
set theResult to gMiscXobject(mInsureFolder, gSavePath & gFileSep)
if theResult <> 0 then
alert("Problem creating Road Construction folder as" && gSavePath)
end if
end if
if objectp(gMiscXobject) then
gMiscXobject(mdispose)
end if
set filePath to gSavePath & "PREFS"
set readObject to FileIO(mnew, "read", filePath)
if not objectp(readObject) then
set prefsString to "1,1,1"
set writeObject to FileIO(mnew, "write", filePath)
writeObject(mWriteString, prefsString)
writeObject(mdispose)
else
readObject(mdispose)
end if
set gIOerrors to [33: "File directory full", 34: "Volume full", 35: "Volume not found", 36: "I/O Error", 37: "Bad file name", 38: "File not open", 42: "Too many files open", 43: "File not found", 49: "File open with write permission", 56: "No such drive", 65: "No disk in drive", 120: "Directory not found"]
set gPoint to the number of cast "point"
end
on keyDownHandler
if the commandDown then
if (the key = "w") or (the key = "q") or (the key = ".") then
cleanUpXobjects()
quit()
end if
end if
end
on cleanUpXobjects
if objectp(gFlushObject) then
gFlushObject(mdispose)
end if
if objectp(gMiscXobject) then
gMiscXobject(mdispose)
end if
if objectp(gPrinterObject) then
gPrinterObject(mdispose)
end if
if objectp(gFixpal) then
gFixpal(mdispose)
end if
if objectp(gCopyObj) then
gCopyObj(mdispose)
end if
if gCPU = #Mac then
if objectp(gRearWindowObject) then
gRearWindowObject(mdispose)
end if
end if
closeXLib()
end
on stopMovie
set the trace to 0
cleanUpXobjects()
end
on activateRearWindow
if factory("RearWindow") = 0 then
openXLib(gXobjPath & "RearWindow XObj")
end if
if objectp(gRearWindowObject) then
gRearWindowObject(mdispose)
end if
makeObjIfNeeded()
gRearWindowObject(mPatToWindow, -5)
end
on showObjectProps object
put "properties :"
repeat with x = 1 to count(object)
set propName to getPropAt(object, x)
put propName && getProp(object, propName)
end repeat
put RETURN & "------"
end
on makeObjIfNeeded
if not objectp(gRearWindowObject) then
set gRearWindowObject to RearWindow(mnew, "M")
if value(gRearWindowObject) < 0 then
alert("System error" && gRearWindowObject && "trying to create the RearWindow object in RAM (multiple-monitor config).")
stopMovie()
exit
end if
if the freeBlock < gRearWindowObject(mGetMemoryNeeded) then
if objectp(gRearWindowObject) then
gRearWindowObject(mdispose)
set gRearWindowObject to RearWindow(mnew, "S")
end if
if value(gRearWindowObject) < 0 then
alert("System error" && gRearWindowObject && "trying to create the RearWindow object in RAM (single-monitor config).")